package phaseutil

import (
	"context"

	corev1 "k8s.io/api/core/v1"
	"sigs.k8s.io/controller-runtime/pkg/client"

	"gopkg.openfuyao.cn/cluster-api-provider-bke/utils/constant"
)

func GetLocalKubeConfig(ctx context.Context, c client.Client) ([]byte, error) {
	// get kubeconfig
	localKubeConfigSecret := &corev1.Secret{}
	if err := c.Get(ctx, constant.GetLocalKubeConfigObjectKey(), localKubeConfigSecret); err != nil {
		return nil, err
	}
	localKubeConfig := localKubeConfigSecret.Data["config"]
	return localKubeConfig, nil
}
